package com.zdc.learn.netty.codec;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.string.StringEncoder;

public class CodecClientChannel extends ChannelInitializer<SocketChannel> {
    @Override
    protected void initChannel(SocketChannel ch) throws Exception {
        ChannelPipeline pipeline = ch.pipeline();
        //粘包和拆包问题解决方案示例
        pipeline.addLast("encoder",new MessageEncoder());
        pipeline.addLast(new CodecClientHandler());
        //粘包和拆包问题示例
        //pipeline.addLast(new CodecClientHandler2());
    }
}
